package com.lakeworks.common.enums;

import static java.util.Arrays.stream;

public enum MaterialType implements ValueEnum<MaterialType> {


    /**
     * 加拿大鹅
     */
    GENERALBRAND(1 << 1),

    /**
     * 大牌补价
     */
    SPECIALBRAND(1 << 2),

    /**
     * PU
     */
    PU(1 << 3),

    /**
     * 真皮
     */
    CORTEX(1 << 4),

    /**
     * 真丝
     */
    PURESILK(1 << 5),

    /**
     * 皮毛一体
     */
    ONEFUR(1 << 6);


    private int value;

    MaterialType(int value) {
        this.value = value;
    }

    public static int sum() {
        return stream(values()).mapToInt(MaterialType::value).reduce(0, (a, b) -> a | b);
    }

    public static MaterialType[] explode(int value) {
        return stream(values()).filter(s -> (s.value() & value) == s.value()).toArray(MaterialType[]::new);
    }

    @Override
    public int value() {
        return this.value;
    }


}
